#include <stdio.h>
 
int main(void){
    char name[]="tom";
    int age = 18;
    float score = 85.5;
    // 准备字符串缓冲区
    char strBuffer[1024];
    // 将格式化好的字符串保存到字符串缓冲区strBuffer
    sprintf(strBuffer,
        "姓名:%s,年龄:%d,成绩:%.2f",name,age,score);
    printf("%s\n",strBuffer);
    // 目标业务是数据字符串
    char strData[]="tom成绩:60.5,jerry成绩:65.5,kitty成绩:89.5";
    double scores[3];
    sscanf(strData,
        "tom成绩:%lf,jerry成绩:%lf,kitty成绩:%lf",
        &scores[0],&scores[1],&scores[2]);
    printf("scores[0]=%.2f\n",scores[0]);
    printf("scores[1]=%.2f\n",scores[1]);
    printf("scores[2]=%.2f\n",scores[2]);
    return 0;
}